﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="Themes/Default/Form.css" rel="stylesheet" type="text/css" />
	<link href="Themes/Default/CommonCtrl.css" rel="stylesheet" type="text/css" />
	<link href="Themes/Default/TreeView.css" rel="stylesheet" type="text/css" />
	<link href="Themes/Default/Control.css" rel="stylesheet" type="text/css" />

	<script src="Core/Common.js" type="text/javascript"></script>

	<script src="Core/Extent.js" type="text/javascript"></script>

	<script src="Core/Sub.js" type="text/javascript"></script>

	<script src="UI/CommonCtrl.js" type="text/javascript"></script>

	<script src="UI/TreeView.js" type="text/javascript"></script>

	<script src="UI/Control.js" type="text/javascript"></script>

	<script src="UI/AccountTree.js" type="text/javascript"></script>

	<script language="javascript" type="text/javascript">
			
		var usertree_ = null;
		
		function init()
		{
			Core.UI.PagePanel.Create('');
			var page_ctrl = new Core.UI.TabControl(
				Core.UI.PagePanel,
				{
					ID: "tabctrl",
					Css: "tabctrl ct_tab",
					Margin: 1,
					Tabs: [
						{ 
							ID: "TAB0", MinWidth: 100, Text: "所有员工", IsSelected: true,
							Controls: [
								{ 
									ID: "bottompanel", Css: "bottompanel", Margin: [0, 6, 6, 6], Height: 32, DockStyle: Core.UI.DockStyle.Bottom,
									Controls: [
										{ ID: "btnok_container", Css: "ct_custom_default_button", Width: 64, DockStyle: Core.UI.DockStyle.Right }
									]
								},
								{ ID: "usertree_conteiner", Css: "ct_treeview", Margin: 6, DockStyle: Core.UI.DockStyle.Fill }
							]
						}
					],
					DockStyle: Core.UI.DockStyle.Fill
				}
			);
			
			var btnok = new Core.UI.Button(page_ctrl.GetTabPanelContainer("TAB0", "bottompanel/btnok_container"), { Text: "确定", TabIndex: 1 });
			btnok.OnClick.Attach(
				function()
				{
					var ids = [];
					var depts = {};
					var users = {};
					var checkedNodes = usertree_.GetCheckedNodes();
					for (var i in checkedNodes)
					{
						var u = checkedNodes[i].GetTag().Data;
						var d = checkedNodes[i].GetParent().GetTag().Data;
						users[u.ID] = u;
						depts[d.ID] = d;
						ids.push(u.ID);
						ids.push(d.ID);
					}
					
					if (CurrentWindow.GetTag() != null && CurrentWindow.GetTag().OnSelected != undefined)
					{
						CurrentWindow.GetTag().OnSelected(ids.join(","), users, depts);
					}
					
					CurrentWindow.Close();
				}
			);
			
			var usertree_conf = {};
			
			if (CurrentWindow.GetTag() == undefined || CurrentWindow.GetTag().DSConfig == undefined)
			{
				usertree_conf.DSConfig = {
					ShowUser: true,
					ShowGroup: false,
					ShowUserCheckBox: true,
					ShowCommFriends: false
				};
			}
			else
			{
				usertree_conf.DSConfig = CurrentWindow.GetTag().DSConfig;
			}
			
			usertree_ = new Core.UI.AccountTree(page_ctrl.GetTabPanelContainer("TAB0", "usertree_conteiner"), usertree_conf);  
			usertree_.RefreshTree(
				function()
				{
					usertree_.Select(Core.EmptyCallback , "/COMPANY");
				},
				true
			); 
		}
	</script>
</head>
<body>
</body>
</html>
